package point

import (
	rentalpb "car_rental/rental/api/gen/v1"
	"context"
	"github.com/golang/protobuf/proto"
	"hash/fnv"
)

var point = []string{
	"中关村",
	"天安门",
	"陆家嘴",
	"迪士尼",
	"天河体育中心",
	"广州塔",
}

type Manager struct {
}

func (*Manager) Resolve(c context.Context, loc *rentalpb.Location) (string, error) {

	b, err := proto.Marshal(loc)

	if err != nil {
		return "", err
	}

	h := fnv.New32()

	_, err = h.Write(b)

	return point[int(h.Sum32())%len(point)], nil

}
